package com.mdd.admin.controller.yylq;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.yylq.ITAppCorporateFinanceApplicationRecordService;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.validate.yylq.TAppCorporateFinanceApplicationRecordCreateValidate;
import com.mdd.admin.validate.yylq.TAppCorporateFinanceApplicationRecordSearchValidate;
import com.mdd.admin.validate.yylq.TAppCorporateFinanceApplicationRecordUpdateValidate;
import com.mdd.admin.vo.yylq.TAppCorporateFinanceApplicationRecordDetailVo;
import com.mdd.admin.vo.yylq.TAppCorporateFinanceApplicationRecordListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/adminapi/yylq/appCorporateFinanceApplicationRecord")
@Api(tags = "羊羊领企---企业融资申请记录管理")
public class TAppCorporateFinanceApplicationRecordController {

    @Resource
    ITAppCorporateFinanceApplicationRecordService iTAppCorporateFinanceApplicationRecordService;

    @GetMapping("/list")
    @ApiOperation(value="企业融资申请记录列表")
    public AjaxResult<PageResult<TAppCorporateFinanceApplicationRecordListedVo>> list(@Validated PageValidate pageValidate,
                                                                                      @Validated TAppCorporateFinanceApplicationRecordSearchValidate searchValidate) {
        PageResult<TAppCorporateFinanceApplicationRecordListedVo> list = iTAppCorporateFinanceApplicationRecordService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="企业融资申请记录详情")
    public AjaxResult<TAppCorporateFinanceApplicationRecordDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        TAppCorporateFinanceApplicationRecordDetailVo detail = iTAppCorporateFinanceApplicationRecordService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "企业融资申请记录新增")
    @PostMapping("/add")
    @ApiOperation(value="企业融资申请记录新增")
    public AjaxResult<Object> add(@Validated @RequestBody TAppCorporateFinanceApplicationRecordCreateValidate createValidate) {
        iTAppCorporateFinanceApplicationRecordService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "企业融资申请记录编辑")
    @PostMapping("/edit")
    @ApiOperation(value="企业融资申请记录编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody TAppCorporateFinanceApplicationRecordUpdateValidate updateValidate) {
        iTAppCorporateFinanceApplicationRecordService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "企业融资申请记录删除")
    @PostMapping("/del")
    @ApiOperation(value="企业融资申请记录删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iTAppCorporateFinanceApplicationRecordService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
